package gui;

import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

import data.ActionList;
import data.model.Action;

public class ActionPanel extends JPanel {

	private static JTextArea actText;
	
	
	public ActionPanel() {
		Border border = BorderFactory.createTitledBorder(BorderFactory.createBevelBorder( BevelBorder.LOWERED),
				"Actions",TitledBorder.CENTER,TitledBorder.TOP);
		setBorder(border);
		actText = new JTextArea();
		add(actText);
		
		updateActions();
	}
	
	/**
	 * refresh list of actions from data
	 */
	public static void updateActions()
	{
		Object[] acts = ActionList.getList();
		
		StringBuilder sb = new StringBuilder("");
		
		for(int i = 1; i < acts.length; i++)
		{
			if(acts[i] != null)
				sb.append(((Action) acts[i]).getActName() + "\n");
		}
		
		actText.setText(sb.toString());
	}


}
